<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <a href="www.baidu.com" id="qw">qqq</a>
  <script>
    var sd = document.getElementById("qw");
    sd.onclick = function (e) {
      e = e || window.event;
      console.log(123);
      // 阻止默认行为
      // return false;
      // dom方法
      // e.preventDefault()
        //低版本兼容方法
        // e.returnValue = false;
    }
  </script>

</body>
</html>